package events
{
	import flash.events.Event;

	public class GameEventManager
	{
		
		private static var handlers:Object = new Object;
		
		public function GameEventManager()
		{
		}
		
		private static function getHandler(name:String):GameEventExcuter
		{
			if(!handlers[name])			
				handlers[name] = new GameEventExcuter;
			return handlers[name] as GameEventExcuter;
		}
		
		public static function disGameEvent(name:String,event:Event):void
		{
			var tempHandler:GameEventExcuter = getHandler(name);	
			tempHandler && tempHandler.dispatchEvent(event);
		}
		
		public static function addListener(name:String,eventType:String,handler:Function):void
		{
			var tempHandler:GameEventExcuter = getHandler(name);	
			if(tempHandler)
			{
				tempHandler.addHandler(eventType,handler);
			}
		}
		
		public static function removeHandler(name:String,eventType:String):void
		{
			var tempHandler:GameEventExcuter = getHandler(name);	
			if(tempHandler)
			{
				tempHandler.removeHandler(eventType);
			}
		}
		
	}
}